%% Setting Directory & Paths
clear
cd /yourpath/FinalReplicationPackage/output/figures
addpath('/yourpath/FinalReplicationPackage/data/simulations')

alpha_array = [-1:0.2:1.8]
gamma = 0.484;
%gamma = 0.692;

for x = 1:length(alpha_array)

    filename = sprintf('alpha=%.1f_gamma=%.3f_weather_largersample.mat', alpha_array(x), gamma);
    load(filename)

    d_present(x) = mean(df_reg.d_present)
    d_past(x) = mean(df_reg.d_past)

    %%
    clf

    f = scatter(1:length([e_i1, e_i2, e_i3, e_i4]), [e_i1, e_i2, e_i3, e_i4], [], [0.60 0.7740 0.10])
    hold on
    f = scatter(1:length([u_i1, u_i2, u_i3, u_i4]), [u_i1, u_i2, u_i3, u_i4], [], [0 0.5 0.3])
    hold on
    f1 = xline(0,'-','t = 1')
    hold on
    f2 = xline(3204,'-','t = 2')
    hold on
    f3 = xline(6406,'-','t = 3')
    hold on
    f4 = xline(9612,'-','t = 4')
    xlim([0 length([e_i1, e_i2, e_i3, e_i4])])
    xlab = xlabel("Individual i in Period t");
    set(gca,'XTick',[])    
    ylab = ylabel("Individual's utility (u_{it}) or cost (e_{it})");
    lgd = legend('cost', 'utility', 'Location', 'southoutside','Orientation', 'horizontal')
    %ttl = title(sprintf('\\gamma = %.3f, \\alpha = %.3f', gamma, alpha));
    fontsize(lgd,12,'points')
    %fontsize(ttl,12,'points')
    fontsize(f1,12,'points')
    fontsize(f2,12,'points')
    fontsize(f3,12,'points')
    fontsize(f4,12,'points')
    fontsize(ylab,12,'points')
    fontsize(xlab,12,'points')
    filename = sprintf('utilcost_distribution-gamma=%.3f-alpha=%.3f.png', gamma, alpha);

    saveas(f,filename);

end
